package HomeWork2;

/**
 * 先去判断输入的数值是否为三角形
 *两边之和大于第三边(每条边都得判断一次)
 * 然后再去求三角形的面积
 */

public class Triangle {
    //field
    public float firstEdge;
    public float secondEdge;
    public float thirdEdge;

    public void squaring() {
        if(firstEdge + secondEdge > thirdEdge && firstEdge + thirdEdge > secondEdge && secondEdge + thirdEdge > firstEdge) {
            float p = (firstEdge + secondEdge + thirdEdge) / 2;
            double Area = Math.sqrt(p * (p - firstEdge) * (p - secondEdge) * (p - thirdEdge));
            System.out.println("三角形的面积是：" + Area);
        }else{
            System.out.println("你输入的不是三角形！");
        }
    }

    public static void main(String [] args){
        Triangle t = new Triangle();
        t.firstEdge = 30;
        t.secondEdge = 40;
        t.thirdEdge = 50;
        t.squaring();
    }

}
